/**
 * @作者 chengxinxiaofeng
 * @时间 2019年7月15日10:30:20
 */
package com.chinaunicom.tour.sys.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
@ComponentScan(basePackages = { "com.chinaunicom.tour.sys"})
public class SwaggerConfig { 
    @Bean
    public Docket buildDocket() {
    return new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(buildApiInf())
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.chinaunicom.tour.sys"))// 需要生成文档的包的位置
        .paths(PathSelectors.any())
        .build();
    }

    private ApiInfo buildApiInf() {
    return new ApiInfoBuilder()
        .title("引擎计划二期项目实战")
        .description("Swagger2构建RESTful APIs")
        .termsOfServiceUrl("http://localhost")
        .contact(new Contact("24017867", "http://localhost", ""))
        .version("1.0")
        .build();
    }
}
